package com.bmps.springcloud.insuredmicroservice.service.underwrite.strategy.minordeath;

import com.bmps.springcloud.insuredmicroservice.constant.accept.AcceptConstant;
import com.bmps.springcloud.insuredmicroservice.constant.accept.StrategyConstant;
import com.bmps.springcloud.insuredmicroservice.constant.accept.UnderWriteConstant;
import com.bmps.springcloud.insuredmicroservice.model.accept.ProcessModel;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.AcceptRequestDataModel;
import com.bmps.springcloud.insuredmicroservice.model.accept.resquest.ProductModel;
import com.bmps.springcloud.insuredmicroservice.model.underwrite.InsuredModel;
import com.bmps.springcloud.insuredmicroservice.service.RedisService;
import com.bmps.springcloud.insuredmicroservice.service.calculate.DeathLiabilityInsuranceService;
import com.bmps.springcloud.insuredmicroservice.util.accept.AcceptUtil;

import java.math.BigDecimal;

/**
 * AAT046未成年人死亡累计保额
 * @author :（Jacob）
 * @date : 2020/2/12 
 **/
public class Aat046MinorDeathStrategy implements MinorDeathStrategy{
    @Override
    public InsuredModel checkDeathLiabilityByRiskCode(AcceptRequestDataModel acceptRequestDataModel, ProductModel productModel, RedisService redisService, DeathLiabilityInsuranceService deathLiabilityInsuranceService) {
        ProcessModel processModel = BasicMinorDeath.checkDeathLiabilityByRiskCode(acceptRequestDataModel, productModel,
                redisService, deathLiabilityInsuranceService);
        if (processModel.getYear() >= StrategyConstant.AGE_TEN && processModel.getYear() <= StrategyConstant.AGE_SEVENTEEN &&
                AcceptUtil.compareTo(processModel.getAmount(), BigDecimal.valueOf(UnderWriteConstant.FIVE_HUNDRED_THOUSAND)) == 1) {
            return AcceptUtil.getInsuredResponse(UnderWriteConstant.UNDER_WRITE_FIAL_CODE,
                    UnderWriteConstant.UNDER_WRITE_NUGG0048_MESSAGE);
        }
        if (processModel.getDay() >= StrategyConstant.DAY_THIRTY && processModel.getYear() <= StrategyConstant.AGE_NINE &&
                AcceptUtil.compareTo(processModel.getAmount(), BigDecimal.valueOf(UnderWriteConstant.TWO_HUNDRED_THOUSAND)) == 1) {
            return AcceptUtil.getInsuredResponse(UnderWriteConstant.UNDER_WRITE_FIAL_CODE,
                    UnderWriteConstant.UNDER_WRITE_NUGG0047_MESSAGE);
        }
        return AcceptUtil.getInsuredResponse(AcceptConstant.RESULT_SUCCESS_CODE, AcceptConstant.RESULT_SUCCESS_MESSAGE);
    }
}
